<template>
  <div>
    <el-menu
      :default-active="defaultActive"
      class="el-menu-vertical-demo"
      background-color="#3D5F81"
      text-color="#fff"
      active-text-color="#ffd04b"
      unique-opened
      router
    >
      <el-menu-item index="/home">
        <i class="el-icon-menu"></i>
        <span slot="title">首页</span>
      </el-menu-item>

      <el-submenu
        v-for="item in $store.getters.getUser.menus"
        :key="item.id"
        :index="item.id.toString()"
      >
        <template slot="title">
          <i :class="item.icon"></i>
          <span>{{ item.title }}</span>
        </template>
        <el-menu-item
          v-for="menu in item.children"
          :index="menu.url"
          :key="menu.id"
          >{{ menu.title }}</el-menu-item
        >
      </el-submenu>
    </el-menu>
  </div>
</template>
<script>
export default {
  data() {
    return {
      defaultActive: "/home",
    };
  },
  mounted() {
    this.defaultActive = this.$route.path;
    console.log(this.$store.getters);
  },
};
</script>

<style lang="less"scoped>
.el-menu {
  min-height: 840px;
}
</style>
